package com.ozo.boot.common.redis.config;

import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.redis.util.RedisLockRegistry;

/**
 * 分布式锁配置
 *
 * @author qinagesoft
 * @date 2024-07-12
 */
@Configuration
@EnableConfigurationProperties({CacheProperties.class})
public class RedisLockConfiguration {

    @Bean
    public RedisLockRegistry redisLockRegistry(RedisConnectionFactory redisConnectionFactory, CacheProperties cacheProperties) {
        return new RedisLockRegistry(redisConnectionFactory, cacheProperties.getRedis().getKeyPrefix());
    }

}
